package cn.z2huo.knowledge.basic.operator.modulo;

/**
 * <p>模运算 和 余运算
 *
 * @author z2huo
 */
public class ModuloTest {

    /**
     * 正数
     */
    public static void positiveNumber() {
        int a = 10;
        int b = 3;
        System.out.println(a / b);
        System.out.println(a % b);
    }

    /**
     * 被除数为 负数
     */
    public static void negativeNumber() {
        int a = -10;
        int b = 3;
        System.out.println(a / b);
        System.out.println(a % b);
        System.out.println(((a % b) + b) % b);
    }

    /**
     * 除数为 负数
     */
    public static void negativeNumber2() {
        int a = 10;
        int b = -3;
        System.out.println(a / b);
        System.out.println(a % b);
        System.out.println(((a % b) + b) % b);
    }

    public static void main(String[] args) {

        System.out.println(Math.ceilMod(10, 3));
        System.out.println(Math.floorMod(10, 3));
        System.out.println(Math.ceilMod(-10, 3));
        System.out.println(Math.floorMod(-10, 3));

        System.out.println();
        positiveNumber();
        System.out.println();
        negativeNumber();
        System.out.println();
        negativeNumber2();
    }
}
